/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package lesson10;


/**
 *
 * @author netcracker
 */
public class OneReadThread implements Runnable {

    IVector vector;

    public OneReadThread(IVector vector) {
        this.vector = vector;
    }

    @Override
    public synchronized void run() {
        for (int i = 0; i < vector.getLength(); i++) {

            while (!vector.isEdited()) {
                Thread.yield();
            }
            System.out.println("Read:  "+ vector.get(i)+" from position "+i);
            vector.setEdited(false);
            notifyAll();
        }
    }
}